﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Domain.MainModule.Entities;
using Infraestructure.Data.MainModule.UnitOfWork;
using Infraestructure.CrossCutting.Logging;
using Domain.MainModule.OrderDetails;
using Infraestructure.Data.MainModule.Repositories;

namespace Infraestructure.Data.MainModule.Tests.RepositoriesTests
{
    /// <summary>
    ///This is a test class for OrderDetailRepositoryTest and is intended
    ///to contain all OrderDetailRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class OrderDetailRepositoryTest : RepositoryTestsBase<OrderDetail>
    {
       public override System.Linq.Expressions.Expression<Func<OrderDetail, bool>> FilterExpression
        {
            get { return a => a.OrderDetailId == TestConstants.Instance.ORDER_DETAIL_ID; }
        }

        public override System.Linq.Expressions.Expression<Func<OrderDetail, Guid>> OrderByExpression
        {
            get { return a => a.OrderDetailId; }
        }

        /// <summary>
        ///A test for FindOrderDetail
        ///</summary>
        [TestMethod()]
        public void FindOrderDetailById_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IOrderDetailRepository repository = new OrderDetailRepository(context, traceManager);

            OrderDetailIdSpecification spec = new OrderDetailIdSpecification(TestConstants.Instance.ORDER_DETAIL_ID);

            //Act
            OrderDetail orderDetail = repository.FindOrderDetail(spec);

            //Assert
            Assert.IsNotNull(orderDetail);
        }

        /// <summary>
        ///A test for FindOrderDetail
        ///</summary>
        [TestMethod()]
        public void FindOrderDetailByOrderId_Invoke_Test()
        {
            //Arrange 
            IMainModuleUnitOfWork context = GetUnitOfWork();
            ITraceManager traceManager = this.GetTraceManager();
            IOrderDetailRepository repository = new OrderDetailRepository(context, traceManager);

            OrderDetailOrderIdSpecification spec = new OrderDetailOrderIdSpecification(TestConstants.Instance.ORDER_ID);

            //Act
            IEnumerable<OrderDetail> orderDetail = repository.FindOrderDetails(spec);

            //Assert
            Assert.IsNotNull(orderDetail);
        }
    }
}
